package cn.startom.config;

import cn.startom.sjdzpsdk.ORTicketService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
@ConditionalOnClass(ORTicketService.class)
@EnableConfigurationProperties(ORTicketProperties.class)
public class ORTicketConfig {
    @Autowired
    private ORTicketProperties properties;
    @Bean
    @ConditionalOnMissingBean
    public ORTicketService orTicketService(){

        ORTicketService service=new ORTicketService(
                properties.getDomain(),
                properties.getPid(),
                properties.getSecret()
        );
        return service;
    }

}
